package org.xq.shop.maxaishop.consumer;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import sy.mqapi.Producer;

import java.io.IOException;

@Configuration
public class MqConfig {
    @Value("${mq.host}")
    private String host;    //MQ Broker 地址
    @Value("${mq.port}")
    private int port;       //MQ Broker 端口号
    @Value("${mq.name}")
    private String name;
    //MQ主题
    private String topic = "topicOrder";

    @Bean
    public Producer getProducer() {
        //消息提供者
        Producer producer = null;
        try {
            producer = new Producer(host, port, name, topic);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return producer;
    }

}
